package config

import (
	"io/ioutil"

	"gopkg.in/yaml.v2"
)

var conf *config

type config struct {
	Server struct {
		Port string `yaml:"port"`
	}
	Driver struct {
		Name string `yaml:"name"`
		Url  string `yaml:"url"`
	}
}

func init() {
	conf = new(config)
	bs, err := ioutil.ReadFile("application.yaml")
	if err != nil {
		panic("读取配置出错！")
	}
	err = yaml.Unmarshal(bs, conf)
	if err != nil {
		panic("加载配置出错！")
	}
}

func GetConf() *config {
	return conf
}
